package com.wqr.mobile.android.ui.pager;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;

public class ImgPagerAdapter extends PagerAdapter
// implements ImageTaskCallBack
{
	private static final String TAG = ImgPagerAdapter.class.getSimpleName();
	private int mImageNum;
	private BaseViewAdapter mImageAdapter;

	public ImgPagerAdapter(int imageNum, BaseViewAdapter imageAdapter) {
		this.mImageNum = imageNum;
		this.mImageAdapter = imageAdapter;
	}

	@Override
	public void destroyItem(View container, int position, Object view) {
		ViewPager localViewPager = (ViewPager) container;
		View localView = (View) view;
		localViewPager.removeView(localView);
	}

	@Override
	public int getCount() {
		return mImageNum;
	}

	@Override
	public Object instantiateItem(View container, int position) {
		Log.i(TAG, "instantiateItem-->" + "container size=" + ((ViewPager) container).getCurrentItem() + ",position=" + position);
		View v = mImageAdapter.getView(position);
		((ViewPager) container).addView(v);
		return v;
	}

	@Override
	public boolean isViewFromObject(View view, Object object) {
		return view == ((View) object);
	}

	// @Override
	// public void onTaskFinish(DownloadTaskResult result) {
	// result.getImageView().setImageBitmap(result.getBitmap());
	// }
	//
	// @Override
	// public DownloadTaskResult onDownloadImage(DownloadParams params) {
	// return new DownloadTaskResult(params.getImageView(), mNetworkManager.downloadImages(ctx, params.getUrl()));
	// }
}
